const db = wx.cloud.database();
Page({
  options: {
    addGlobalClass: true,
  },
  data: {
    themeColor:'blue',
    ScreenBrightness:0.5,
    showHome:false,
    cardCur: 0,

    
    iconList: [
  
    {
      icon: 'list',
      color: 'red',
      name: '发布作业'
    }, {
      icon: 'friend',
      color: 'orange',
      name: '学生管理'
    }, {
      icon: 'edit',
      color: 'yellow',
      badge: 0,
      name: '作业管理'
    }, 
    {
      icon: 'notice',
      color: 'yellow',
      badge: 0,
      name: '学生考勤'
    }, 
  //  {
  //     icon: 'appreciate',
  //     color: 'olive',
  //     badge: 22,
  //     name: '关于我们'
    // }
  ],
    gridCol:5,
    cur : 0,
    avatarUrl: '',
    userInfo: {},
    userName: 'null',
    userClass: 'null',
    elements: [{
        title: '题库',
        name: 'answer',
        icon: 'question',
        color: 'blue'
      },
      {
        title: '学习教材',
        name: 'order',
        icon: 'like',
        color: 'red'
      },
      {
        title: '练习',
        name: 'exercise',
        icon: 'copy',
        color: 'cyan'
      },
      {
        title: '视频课程',
        name: 'video',
        icon: 'video',
        color: 'green'
      },
      {
        title: '关于',
        name: 'about',
        icon: 'settings',
        color: 'pink'
      },
    ]
  },  
  goshequ(e){
    var index = e.currentTarget.dataset.id
    if(index == 0){
      wx.navigateTo({
        url: '/pages/issue/issue',
      })
    }else if(index == 1){
      wx.navigateTo({
        url: '/pages/students/students',
      })
    }else if(index == 2){
      wx.navigateTo({
        url: '/pages/Correction/Correction',
      })
    }else if(index == 3){
      wx.navigateTo({
        url: '/pages/dkjg/dkjg',
      })
    }
    // wx.navigateTo({
    //   url: '/pages/dynamic/dynamic?cur=' +  e.currentTarget.dataset.id,
    // })
  },

  onLoad: function(options) {
    db.collection('userInfo').get()
    .then(res => {
      console.log(res)
        this.setData({
          userInfo: res.data[0].userInfo,
          avatarUrl: res.data[0].avatarUrl,
          userName: res.data[0].name,
          userClass: res.data[0]._class,
        })
    }).catch(err => {
      console.log(err)
    })
  },
})